<?php if ($this->st_registry->registry('admin/catalog/category/message')) : ?>
    <div class="stdWidth autoCenter message">
        <?php echo $this->st_registry->getFlashMessage('admin/catalog/category/message'); ?>
    </div>
<?php endif; ?>
<?php $pagData = $paginator->getPages('slider'); ?>
<?php echo form_open_multipart('admin/catalog/category/index', array('id' => 'frmCategoryGridView')); ?>
<?php echo fx_control::newInstance('formKey')->createType('hidden')->setData('value', random_string('unique', 16))->render(); ?>
<?php echo fx_control::newInstance('category_ids')->createType('hidden')->setData('value', $category_ids)->render(); ?>
    <input type="hidden" class="pageIndex" id="categoryPageIndex" value="<?php echo $paginator->getCurrentPageNumber() ?>" name="page"/>
    <div id="box">
        <div id="title">
            <h4><?php echo $module['title'] ?></h4>
        </div>
        <div id="toolBar">
            <ul>
                <li class="new"><a class="flashEditor" href="<?php echo site_url('admin/catalog/category/edit', true) ?>"><span>New</span></a></li>
                <li class="selectAll"><a href="#" onclick="return selectAll('chkCategory', 'category_ids', '<?php echo site_url('admin/grid/select/category_model',true)?>', 'categoryItemSelected', 'categorySelectedValueHidden')"><span>Select All</span></a></li>
                <li><a href="#" onclick="return unSelectAll('chkCategory', 'category_ids', 'categoryItemSelected', 'categorySelectedValueHidden')"><span>Unselect All</span></a></li>
                <li class="select"><a href="#" onclick="return selectVisible('chkCategory', 'category_ids', 'categoryItemSelected', 'categorySelectedValueHidden')"><span>Select Visible</span></a></li>
                <li class="first"><a href="#" onclick="return unSelectVisible('chkCategory', 'category_ids', 'categoryItemSelected', 'categorySelectedValueHidden')"><span>Unselect Visible</span></a></li>
            </ul>
        </div>
        <div id="informationTable">
            <div id="action">
                <input name="btnSubmit" type="submit" value="Search" class="btnBlue left"/>
                <input name="btnReset" type="button" value="Reset" class="btnBlue left btnReset" />
                <div id="selectAction" class="right">
                    <?php echo fx_control::newInstance('selectMassAction')
								 ->createType('option')
								 ->addOption('', '')
								 ->addOption('Active', site_url("admin/catalog/category/massActive", true))
								 ->addOption('Deactive', site_url("admin/catalog/category/massDeactive", true))
								 ->addClass('massSelectAction')
								 ->addClass('stdSelect')
								 ->render(); 
					?>
					<input type="button" class="btnBlue" id="btnActiveAction" value="Action" onclick="activeMassAction('frmCategoryGridView', 'selectMassAction')" />
                </div>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('categoryPageIndex', 'frmCategoryGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('categoryPageIndex', 'frmCategoryGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
            <div id="table">
                <table id="gridview">
                    <thead>
                        <tr class="columns">
                            <input type="hidden" name="categoryOrder[name]" value="<?php echo $sorter->getName() ?>" id="categoryOrder"/>
                            <input type="hidden" name="categoryOrder[direction]" value="<?php echo $sorter->getDirection() ?>" id="categoryOrderDirection"/>
                            <th></th>
                            <th class="columnFilter" id="category_id">ID</th>
                            <th class="txtLeft columnFilter" id="category_name">Name</th>
                            <th class="txtLeft columnFilter" id="category_summary">Summary</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                        <tr class="filters">
                            <td colspan="2" width="10%"></td>
                            <td width="40%">
                                <input type="text" name="categoryFilter[name][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('name'); ?>" style="width:98%"/>
                                <input type="hidden" name="categoryFilter[name][type]" value="string"/>
                            </td>
                            <td width="30%">
                                <input type="text" name="categoryFilter[summary][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('summary'); ?>" style="width:98%"/>
                                <input type="hidden" name="categoryFilter[summary][type]" value="string"/>
                            </td>
                            <td class="txtCenter" width="10%">
	                            <?php echo fx_control::newInstance('categoryFilter[is_active][value]')
										 ->createType('option')
										 ->addOption('Any Status', '')
										 ->addOption('All', '')
										 ->addOption('Active', '1')
										 ->addOption('DeActive', '0')
										 ->addClass('stdSelect')
										 ->value($filters->getValue('is_active'))
										 ->render(); 
								?>
								<input type="hidden" name="categoryFilter[is_active][type]" value="equal"/>
                            </td>
                            <td width="20%"></td>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($collection as $category) : ?>
                        <tr id="row_<?php echo $category->getId() ?>" class="activeRow">
                            <input class="editUrl" type="hidden" value="<?php echo $category->getCategoryUrl(); ?>" />
                            <td class="select noActiveRow">
                                <?php echo fx_control::newInstance('category_checkbox[]')
												 ->createType('checkbox')
												 ->value($category->getId())
												 ->addClass('chkCategory')
												 ->removeClass('inputText')
												 ->bindingCheckbox($category_ids_array)
												 ->render();
								?>
                            </td>
                            <td><?php echo $category->getId() ?></td>
                            <td>
                            	<?php echo $category->getName() ?>
                           	</td>
                            <td><?php echo $category->getSummary() ?></td>
                            <td>
                            <?php echo fx_control::newInstance('is_active')
                                 ->createType('matchedText')
                                 ->removeData('id')
                                 ->removeClass('inputText')
                                 ->addOption('Active', '1')
                                 ->addOption('DeActive', '0')
                                 ->value($category->getIsActive())
                                 ->render();
                            ?>
                            </td>
                            <td class="action noActiveRow">
                            	<a class="flashEditor" href="<?php echo site_url('admin/catalog/category/edit/id/' . $category->getId(), true) ?>"><span>Edit</span></a>
                                <a class="flashDelete" id="flashDelete" href="<?php echo site_url('admin/catalog/category/delete/id/' . $category->getId(), true) ?>"><span>Delete</span></a>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('categoryPageIndex', 'frmCategoryGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('categoryPageIndex', 'frmCategoryGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
<?php echo form_close(); ?>
<script language="javascript" type="text/javascript">
	
	//Fancybox
	/*
	jQuery(".fancyBoxActivator").fancybox({
		 'autoScale'		: false,
		 'transitionIn'		: 'none',
		 'transitionOut'	: 'none',
		 'type'				: 'iframe'
	});
	*/
	//Colorbox
	/*
	jQuery(document).ready(function() {
		jQuery(".flashEditor").colorbox({iframe:true, width:"80%", height:"80%"});
	});
	*/
    jQuery("#gridview")
    .decorateTable()
    .lightHoverRow()
    .activePageIndex('pageIndexValue', 'categoryPageIndex', 'frmCategoryGridView')
    .activeSortableAbility("frmCategoryGridView", "columnFilter", "category_", "categoryOrder", "categoryOrderDirection")
    .checkboxCallbackHandler('chkCategory', 'category_ids', 'categoryItemSelected', 'categorySelectedValueHidden')
    .activeResetButton('frmCategoryGridView', 'btnReset', '<?php echo site_url('admin/catalog/category/index', true)?>')
    .activeColorBox('flashEditor');
    jQuery("#flashDelete").click(function(){
        var answ = confirm("Do you want to remove this category");
        if(answ){
            return true;
        }else{
            return false;
        }
    });
</script>